import {
    reqAddressInfo,
    reqUserTrade
} from '@/api'
const state = {
    address: [],
    tradeInfo: {}
}
const actions = {
    // 获取用户地址信息
    async getAddressInfo({
        commit
    }) {
        let result = await reqAddressInfo()
        console.log(result);
        if (result.code === 200) {
            commit('GETADDRESSINFO', result.data)
            return 'OK'
        } else {
            return Promise.reject(new Error('false'))
        }
    },
    // 获取用户订单交易页
    async getUserTrade({
        commit
    }) {
        let result = await reqUserTrade()
        if (result.code === 200) {
            commit('GETUSERTRADE', result.data)
            return 'OK'
        } else {
            return Promise.reject(new Error('false'))
        }
    }
}
const mutations = {
    GETADDRESSINFO(state, address) {
        state.address = address
    },
    GETUSERTRADE(state, tradeInfo) {
        state.tradeInfo = tradeInfo
    }
}
const getters = {}
export default {
    state,
    actions,
    mutations,
    getters
}